<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Cloudflare Workers 代理客户端</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            line-height: 1.6;
            color: #333;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 2rem;
        }

        .header {
            text-align: center;
            color: white;
            margin-bottom: 3rem;
        }

        .header h1 {
            font-size: 3rem;
            margin-bottom: 1rem;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
        }

        .header p {
            font-size: 1.2rem;
            opacity: 0.9;
        }

        .features {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 2rem;
            margin-bottom: 3rem;
        }

        .feature-card {
            background: white;
            border-radius: 10px;
            padding: 2rem;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
        }

        .feature-card:hover {
            transform: translateY(-5px);
        }

        .feature-card h3 {
            color: #667eea;
            margin-bottom: 1rem;
            font-size: 1.5rem;
        }

        .feature-card p {
            color: #666;
            margin-bottom: 1rem;
        }

        .feature-icon {
            font-size: 3rem;
            margin-bottom: 1rem;
        }

        .config-section {
            background: white;
            border-radius: 10px;
            padding: 2rem;
            margin-bottom: 2rem;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        }

        .config-section h3 {
            color: #667eea;
            margin-bottom: 1rem;
        }

        .config-option {
            background: #f8f9fa;
            border-radius: 5px;
            padding: 1rem;
            margin: 1rem 0;
            border-left: 4px solid #667eea;
        }

        .code {
            background: #f1f3f4;
            padding: 0.5rem;
            border-radius: 3px;
            font-family: 'Courier New', monospace;
            font-size: 0.9rem;
        }

        .actions {
            display: flex;
            justify-content: center;
            gap: 2rem;
            flex-wrap: wrap;
        }

        .btn {
            display: inline-block;
            padding: 1rem 2rem;
            border-radius: 50px;
            text-decoration: none;
            font-weight: bold;
            transition: all 0.3s ease;
            text-align: center;
            min-width: 200px;
        }

        .btn-primary {
            background: #667eea;
            color: white;
        }

        .btn-primary:hover {
            background: #5a6fd8;
            transform: translateY(-2px);
            box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
        }

        .btn-secondary {
            background: white;
            color: #667eea;
            border: 2px solid #667eea;
        }

        .btn-secondary:hover {
            background: #667eea;
            color: white;
        }

        .footer {
            text-align: center;
            color: white;
            margin-top: 3rem;
            opacity: 0.8;
        }

        @media (max-width: 768px) {
            .header h1 {
                font-size: 2rem;
            }

            .actions {
                flex-direction: column;
                align-items: center;
            }
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="header">
            <h1>🚀 代理客户端</h1>
            <p>基于 Cloudflare Pages + Functions 的高性能代理转发服务</p>
        </div>

        <div class="features">
            <div class="feature-card">
                <div class="feature-icon">⚡</div>
                <h3>高性能代理</h3>
                <p>基于Cloudflare全球网络，提供极速的代理转发服务</p>
            </div>

            <div class="feature-card">
                <div class="feature-icon">🔧</div>
                <h3>灵活配置</h3>
                <p>支持多种配置方式：环境变量、服务端API、KV存储</p>
            </div>

            <div class="feature-card">
                <div class="feature-icon">🌐</div>
                <h3>全球部署</h3>
                <p>通过GitHub Actions自动部署到Cloudflare Pages</p>
            </div>
        </div>

        <div class="config-section">
            <h3>📋 配置方式</h3>

            <div class="config-option">
                <h4>🔧 零配置部署</h4>
                <p>本项目支持完全通过环境变量配置，无需修改任何代码文件！</p>
                <ol style="text-align: left; margin: 1rem 0;">
                    <li>Fork GitHub 仓库</li>
                    <li>设置 Cloudflare API Token</li>
                    <li>配置环境变量（见下方方式）</li>
                    <li>推送代码自动部署</li>
                </ol>
            </div>

            <div class="config-option">
                <h4>方式一：从服务端获取配置（推荐）</h4>
                <p>在 Cloudflare Pages 设置中添加：</p>
                <div class="code">
                    SERVER_URL=https://your-server.workers.dev<br>
                    SECRET_KEY=your-secret-key<br>
                    SERVICE_KEY=your-service-key
                </div>
            </div>

            <div class="config-option">
                <h4>方式二：直接配置代理地址</h4>
                <p>在 Cloudflare Pages 设置中添加：</p>
                <div class="code">
                    PROXY_URL=https://api.example.com<br>
                    UPDATE_INTERVAL=3600
                </div>
            </div>

            <div class="config-option">
                <h4>方式三：使用KV存储（可选）</h4>
                <p>创建 KV 命名空间并添加 ID：</p>
                <div class="code">
                    PROXY_CACHE_KV_ID=your-kv-namespace-id
                </div>
            </div>
        </div>

        <div class="actions">
            <a href="/api/health" class="btn btn-primary">🔍 健康检查</a>
            <a href="https://github.com/Await-d/cloudflare-workers-proxy" class="btn btn-secondary">📚 查看文档</a>
        </div>

        <div class="footer">
            <p>© 2024 Cloudflare Workers Proxy Client | 基于 Apache-2.0 许可证开源</p>
        </div>
    </div>

    <script>
        // 检查服务状态
        async function checkServiceStatus() {
            try {
                const response = await fetch('/api/health');
                const data = await response.json();

                console.log('Service Status:', data);

            } catch (error) {
                console.error('Health check failed:', error);
            }
        }

        // 页面加载时检查状态
        document.addEventListener('DOMContentLoaded', checkServiceStatus);
    </script>
</body>

</html>